#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <fenv.h>
#include <float.h>
#include <inttypes.h>
#include <iso646.h>
#include <limits.h>
#include <locale.h>
#include <math.h>
#include <setjmp.h>
#include <signal.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <tgmath.h>
#include <time.h>
#include <uchar.h>
#include <unistd.h>
#include <wchar.h>
#include <wctype.h>

// LIB FROM HOME/start/communis/Deploy_store/.qa/main_repo_fn/dir_c_/_c_/_lib
//#include "lib/dirent_1.h"
//#include "lib/fcntl_1.h"
//#include "lib/io_1.h"
//#include "lib/l3p_1.h"
//#include "lib/lc_0.h"
//#include "lib/lc_1.h"
//#include "lib/lc_in.h"
//#include "lib/lc_io.h"
//#include "lib/lc_pipe.h"
//#include "lib/lc_str.h"
//#include "lib/lc_time.h"
//#include "lib/lib_1.h"
//#include "lib/libgen_1.h"
//#include "lib/socket_1.h"
//#include "lib/st_mode_1.h"
//#include "lib/sys_stat_1.h"
//#include "lib/uni_1.h"

#include <aio.h>
#include <arpa/inet.h>
#include <net/if.h>
#include <netdb.h>
#include <netinet/in.h>
#include <signal.h>
#include <sys/ipc.h>
#include <sys/mman.h>
#include <sys/msg.h>
#include <sys/resource.h>
#include <sys/select.h>
#include <sys/sem.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/un.h>
#include <sys/wait.h>

#include <dirent.h>
#include <fcntl.h>
#include <fmtmsg.h>
#include <ftw.h>
#include <getopt.h>
#include <glob.h>
#include <grp.h>
#include <iconv.h>
#include <inttypes.h>
#include <mqueue.h>
#include <poll.h>
#include <pthread.h>
#include <pwd.h>
#include <regex.h>
#include <sched.h>
#include <search.h>
#include <semaphore.h>
#include <signal.h>
#include <spawn.h>
#include <stdarg.h>
#include <stddef.h>
#include <threads.h>
#include <unistd.h>
#include <wchar.h>
#include <wordexp.h>

#define _XOPEN_SOURCE 500
#define N 7
// #define _GNU_SOURCE

// while (*envp != NULL)
//     printf("  %s\n", *(envp++));

// #define errExit(msg)                                                                                                   \
//     do                                                                                                                 \
//     {                                                                                                                  \
//         perror(msg);                                                                                                   \
//         exit(EXIT_FAILURE);                                                                                            \
//     } while (0)

// _GCC_DB from makefile
/* schema

main(){

    int r {{for_itter_variable in row itter}}
    int t {{for_itter_variable in tree itter}}
    int row {{numerus row}}

    int tree_row {{numerus tree in row}}
    int apple_tree {{numerus apple at tree}}
    int apple_all {{integra numerus apple}}

    apple_all = 0;

    printf("Enter numerus row:")
    scanf(row);

    for(r=0;r<row;r++){
        printf("Enter numerus tree in %d row",r);
        scanf(tree_row);

        for(t=0;t<tree_row;t++){
            printf("Enter numerus apple in %d tree in %d row", t, r);
            scanf(apple_tree);

            if(apple_tree < 0){ {{sick tree}}
                printf("%d tree in %d row is sick", t, r);
                continue;
            }

            apple_all += apple_tree;

        }

    }

}

*/

int main(int argc,     // Number of strings in array argv
         char *argv[], // Array of command-line argument strings
         char **envp)  // Array of environment variable strings
{
    int r;   // {{for_itter_variable in row itter}}
    int t;   // {{for_itter_variable in tree itter}}
    int row; //{{numerus row}}

    int tree_row;   // {{numerus tree in row}}
    int apple_tree; // {{numerus apple at tree}}
    int apple_all;  // {{integra numerus apple}}

    apple_all = 0;

    printf("Enter numerus row:\n");
    scanf("%d", &row);

    for (r = 0; r < row; r++)
    {
        printf("Enter numerus tree in %d row\n", r);
        scanf("%d", &tree_row);

        for (t = 0; t < tree_row; t++)
        {
            printf("Enter numerus apple in %d tree in %d row\n", t, r);
            scanf("%d", &apple_tree);

            if (apple_tree < 0)
            { // {{sick tree}}
                printf("%d tree in %d row is sick\n", t, r);
                continue;
            }

            if (apple_tree < 0)
            {
                break;
            }

            apple_all += apple_tree;
        }
    }

    printf("Integra numerus apple : %d", apple_all);

    return 0;
}
